import { createRouter, createWebHashHistory } from 'vue-router'
import routes from './routeList'
import { useRouteStore } from '@/store/route'

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

router.beforeEach((to, from) => {
  //记录左侧菜单当前选中的页面（直接监听name的话 当进入详情页的时候 就不再选中了）
  if (!to.meta.hidden) {
    useRouteStore().menuCurrentRouteName = to.name
  } else if (!from.meta.hidden) {
    useRouteStore().menuCurrentRouteName = from.name
  }
})

export default router
